package io.renren.modules.sys.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.sys.entity.OnshelvesitemEntity;
import io.renren.modules.sys.entity.OnshelvesitemVOEntity;
import io.renren.modules.sys.service.OnshelvesitemService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author Mark
 * @email sunlightcs@gmail.com
 * @date 2019-04-10 10:03:48
 */
@RestController
@RequestMapping("sys/onshelvesitem")
public class OnshelvesitemController {
    @Autowired
    private OnshelvesitemService onshelvesitemService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:onshelvesitem:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = onshelvesitemService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/infoByShelvesId/{shelvesId}")
    @RequiresPermissions("sys:onshelvesitem:infoByShelvesId")
    public R infoByShelvesId(@PathVariable("shelvesId") Integer shelvesId){
        List<OnshelvesitemVOEntity> onshelvesitem = onshelvesitemService.getByShelvesId(shelvesId);

        return R.ok().put("onshelvesitem", onshelvesitem);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sys:onshelvesitem:save")
    public R save(@RequestBody OnshelvesitemEntity onshelvesitem){
        onshelvesitemService.save(onshelvesitem);

        return R.ok();
    }


}
